#include "contests/weekly_180.h"
#include "gtest/gtest.h"

TEST(TestWeeklyContest180, TestProblem5356)
{
    weekly_180::problem_5356::Solution s;
    vector<vector<int>> mat{{3, 7, 8}, {9, 11, 13}, {15, 16, 17}};
    auto result = s.luckyNumbers(mat);
    ASSERT_EQ(result.size(), 1);
    ASSERT_EQ(result[0], 15);
}

TEST(TestWeeklyContest180, TestProblem5357_1)
{
    weekly_180::problem_5357::CustomStack stk(3);
    stk.push(1);
    stk.push(2);
    ASSERT_EQ(stk.pop(), 2);
    stk.push(2);
    stk.push(3);
    stk.push(4);
    stk.increment(5, 100);
    stk.increment(2, 100);
    ASSERT_EQ(stk.pop(), 103);
    ASSERT_EQ(stk.pop(), 202);
    ASSERT_EQ(stk.pop(), 201);
    ASSERT_EQ(stk.pop(), -1);
}

TEST(TestWeeklyContest180, TestProblem5357_2)
{
    weekly_180::problem_5357::CustomStack stk(12);
    stk.push(83);
    stk.increment(2, 60);
    stk.increment(9, 61);
    stk.increment(1, 60);
    stk.push(82);
    stk.push(21);
    stk.push(58);
    stk.increment(8, 8);
    stk.push(22);
    stk.push(80);
    stk.increment(1, 64);
    ASSERT_EQ(stk.pop(), 80);
    ASSERT_EQ(stk.pop(), 22);
    stk.push(24);
}

TEST(TestWeeklyContest180, TestProblem5179)
{
    weekly_180::problem_5179::Solution s;
    TreeNode n1(1), n2(2), n3(3), n4(4);
    n1.right = &n2;
    n2.right = &n3;
    n3.right = &n4;
    auto result = s.balanceBST(&n1);
    TreeNode ans1(1), ans2(2), ans3(3), ans4(4);
    ans2.left = &ans1;
    ans2.right = &ans3;
    ans3.right = &ans4;
    ASSERT_TRUE(treeEqual(result, &ans2));
}

TEST(TestWeeklyContest180, TestProblem5359)
{
    weekly_180::problem_5359::Solution s;
    vector<int> speed{2, 10, 3, 1, 5, 8};
    vector<int> eff{5, 4, 3, 9, 7, 2};
    ASSERT_EQ(s.maxPerformance(6, speed, eff, 2), 60);
    ASSERT_EQ(s.maxPerformance(6, speed, eff, 3), 68);
    ASSERT_EQ(s.maxPerformance(6, speed, eff, 4), 72);
    ASSERT_EQ(s.maxPerformance(6, speed, eff, 5), 72);
}